package com.mallcai.bigdata.ladon.dpl.mapper.peekdata;

import com.mallcai.bigdata.ladon.dpl.entity.peekdata.Peek;
import com.mallcai.bigdata.ladon.dpl.mapper.peekdata.provider.PeekSqlProvider;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
 * @author gst
 * @date 2019-12-30 20:36
 */
@Repository
public interface PeekMapper {

    @InsertProvider(type = PeekSqlProvider.class, method = "insert")
    int insert(Peek peek);

    @UpdateProvider(type = PeekSqlProvider.class, method = "update")
    int update(Peek peek);

    @DeleteProvider(type = PeekSqlProvider.class, method = "delete")
    int delete(Peek peek);

    @SelectProvider(type = PeekSqlProvider.class, method = "getByParams")
    List<Peek> getByParams(@Param("params") Map<String, Object> params);

    @SelectProvider(type = PeekSqlProvider.class, method = "getById")
    Peek getById(@Param("id") Long id);

    @Update({
            "UPDATE " + PeekSqlProvider.TB_PEEK + " SET peek_time = peek_time + 1 " +
                    "WHERE id = #{peekId}"
    })
    int incPeekNum(@Param("peekId") Long peekId);
}
